﻿function GetAnalyze_Policy_Optimize() {
	var myData = [
			['1', '1', '设备1','inside','GigabitEthernet0/0<br>GigabitEthernet0/1', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>All-Inside-Subnets","<img src='images/terminal.png'>Corp-Mail-Server","<img src='images/tcp.png'>Mail_Services","<img src='images/tick.png'>Permit","","Alerts","","Allow individual hosts to vpn to partner services",'2,3','建议合并'],
			['2', '2', '设备1','inside','GigabitEthernet0/0<br>GigabitEthernet0/1', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>FTP_Servers_inside<br><img src='images/terminallist.png'>Web_Servers_group","<img src='images/terminal.png'>10.0.101.0/24<br><img src='images/terminal.png'>10.0.102.0/24<br><img src='images/terminal.png'>10.0.100.0/24<br><img src='images/terminal.png'>10.0.103.0/24<br><img src='images/terminal.png'>10.0.104.0/24","<img src='images/tcp.png'>ftp<br><img src='images/tcp.png'>http<br><img src='images/tcp.png'>https<br><img src='images/tcp.png'>ssh","<img src='images/delete.png'>Deny","","Critical","","",'1,3','被包含，可删除'],
			['3', '3', '设备1','inside','GigabitEthernet0/0<br>GigabitEthernet0/1', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>inside-network/24","<img src='images/terminal.png'>10.1.100.0/24","<img src='images/tcp.png'>ftp","<img src='images/tick.png'>Permit","","Warnings","","",'2,1','包含其它策略'],
			['4', '1', '设备2','outside','GigabitEthernet0/2<br>GigabitEthernet0/3', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>any","<img src='images/terminal.png'>WWW_Server","<img src='images/tcp.png'>http","<img src='images/tick.png'>Permit","","Warnings","","",'3','被包含，可删除'],
			['5', '2', '设备2','outside','GigabitEthernet0/2<br>GigabitEthernet0/3', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>any","<img src='images/terminal.png'>DMZ-network","<img src='images/tcp.png'>http","<img src='images/tick.png'>Permit","","Warnings","","",'1','被包含，可删除'],
			['6', '3', '设备2','outside','GigabitEthernet0/2<br>GigabitEthernet0/3', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>outside-network/24","<img src='images/terminal.png'>Ftp_Server","<img src='images/tcp.png'>ftp","<img src='images/tick.png'>Permit","","Warnings","","",'2','包含其它策略'],
			['7', '1', '设备3','DMZ','GigabitEthernet0/4', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>Remote-net-groups","<img src='images/terminal.png'>Web_Server_group","<img src='images/tcp.png'>HTTP-services","<img src='images/tick.png'>Permit","","Warnings","","",'2,3','包含其它策略'],
			['8', '2', '设备3','DMZ','GigabitEthernet0/4', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>10.1.100.0/24","<img src='images/terminal.png'>FTP_Server_group","<img src='images/tcp.png'>ftp","<img src='images/delete.png'>Deny","","Warnings","","",'1,3','建议合并'],
			['9', '3', '设备3','DMZ','GigabitEthernet0/4', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>partner-dmz-network","<img src='images/terminal.png'>Web_Server_group","<img src='images/tcp.png'>ip","<img src='images/tick.png'>Permit","","Warnings","","",'1,2','建议合并'],
			['10', '1','设备4', 'Global','', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>any","<img src='images/terminal.png'>Cisco","<img src='images/tcp.png'>HTTP-services","<img src='images/tick.png'>Permit","","Warnings","","",'3','建议合并'],
			['11', '2','设备4', 'Global','', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>any","<img src='images/terminal.png'>Youtube","<img src='images/tcp.png'>HTTP-services","<img src='images/delete.png'>Deny","","Warnings","","Marketing, and one of the sales people need access to Youtube for posting product videos",'3','被包含，可删除'],
			['12', '3','设备4', 'Global','', '<input type="checkbox" checked> ', "<img src='images/terminallist.png'>any","<img src='images/terminal.png'>Facebook","<img src='images/tcp.png'>HTTP-services","<img src='images/tick.png'>Permit","","Warnings","","Allow only employees to visit Facebook",'2','建议合并']
	];



		
   // shared reader
    var reader = new Ext.data.ArrayReader({}, [
       			{
							name : 'id'
						}, {
							name : 'index'
						}, {
							name : 'devices'
						}, {
							name : 'type'
						}, {
							name : 'interface'
						}, {
							name : 'Enabled'
						}, {
							name : 'Source'
						}, {
							name : 'Destination'
						}, {
							name : 'Service'
						}, {
							name : 'Action'
						}, {
							name : 'Hits'
						}, {
							name : 'Logging'
						}, {
							name : 'Time'
						}, {
							name : 'Description'
						}, {
							name : 'relational'
						}, {
							name : 'status'
						}
    ]);

    var store = new Ext.data.GroupingStore({
            reader: reader,
            data: myData,
            sortInfo:{field: 'id', direction: "ASC"},
            groupField:'devices'
        });

	
	var sm = new Ext.grid.CheckboxSelectionModel();
	var grid = new Ext.grid.GridPanel({
				store : store,
				columns : [{
							id : 'id',
							header : 'id',
							width : 10,
							sortable : true,
							dataIndex : 'id',
							hidden : true
						}, {
							header : '设备',
							width : 10,
							sortable : true,
							dataIndex : 'devices',
							hidden : true
						}, {
							header : '区域',
							width : 50,
							sortable : true,
							dataIndex : 'type'
						}, {
							header : '接口',
							width : 100,
							sortable : true,
							dataIndex : 'interface'
						}, {
							header : '源地址',
							width : 70,
							sortable : true,
							dataIndex : 'Source'
						}, {
							header : '目的地址',
							width : 100,
							sortable : true,
							dataIndex : 'Destination'
						}, {
							header : '服务',
							width : 70,
							sortable : true,
							dataIndex : 'Service'
						}, {
							header : '动作',
							width : 30,
							sortable : true,
							dataIndex : 'Action'
						}, {
							header : '命中',
							width : 30,
							sortable : true,
							dataIndex : 'Hits'
						}, {
							header : '日志',
							width : 50,
							sortable : true,
							dataIndex : 'Logging'
						}, {
							header : '时间',
							width : 50,
							sortable : true,
							dataIndex : 'Time'
						}, {
							header : '描述',
							width : 70,
							sortable : true,
							dataIndex : 'Description'
						}, {
							header : '相关项',
							width : 70,
							sortable : true,
							dataIndex : 'relational'
						}, {
							header : '优化情况',
							width : 70,
							sortable : true,
							dataIndex : 'status'
						}],
				sm : sm,
				view: new Ext.grid.GroupingView({
		            forceFit:true,
		            startCollapsed : false ,
		           groupTextTpl: '{gvalue}({[values.rs.length]} {[values.rs.length > 1 ? "条" : "条"]})'
		        }),
				

				
				stripeRows : true,
				autoExpandColumn : 'id',
				stateful : true,
				stateId : 'Analyze_Policy_Optimizegrid'
			});

	 var store1 = new Ext.data.JsonStore({
        fields: [{name: 'check'},{name: 'x',type: 'int'}],
        data: [
        {check: '建议合并',x: 15},
        {check: '被包含可删除',x: 23},
        {check: '包含其它策略',x: 8}
        ]
    })
	var centerPanel = new Ext.Panel({

        region : 'center',
        layout : 'border',
				tbar : [
						'选择设备:',
						{xtype: 'textfield',width : 300},
						{
							text : '选择',
							tooltip : '选择',
							handler : function() {
								GetLinkDevice();
							}
						},'-',{
							text : '分析',
							tooltip : '分析',
							handler : function() {
								
							}
						}],
        items: [
        		{
							region: 'north',
							height: 200,
							items : {
						    xtype: 'stackedcolumnchart',
						    store: store1,
						    xField: 'check',
						    xAxis: new Ext.chart.CategoryAxis({
						        title: '优化结果'
						    }),
						    yAxis: new Ext.chart.NumericAxis({
						        title: "数量"
						    }),
						    series: [{
					        displayName: "设备数量",
					        yField: 'x'
						    }],
						    chartStyle: {
						        padding: 10,
						        legend: {
						            display: 'right'
						        }
						    }
							}
							
						},{
							region: 'center',
							layout : 'fit',
							title:'明细表格',
							items : [grid]
						}
        ]

			});
    
    
	return centerPanel;
}